package Test1;

import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class TestDemo7 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int length = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[length];
        int[] b = new int[length];
        for (int i = 0; i < length; i++) {
            a[i] = in.nextInt();
        }
        for (int i = 0; i < length; i++) {
            b[i] = in.nextInt();
        }
        int m = a.length - 1;
        int n = b.length - 1;
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>
                (k,new Comparator<Integer>() {
                    @Override
                    public int compare(Integer o1, Integer o2) {
                        return o2 - o1;
                    }
                });
        for (int i = m; i >= m - k ; i--) {
            int sum1 = a[i];
            for (int j = n; j >= n - k ; j--) {
                int sum2 = b[j];

            }

        }
        for (int i = k; i > 0 ; i--) {
            Integer poll = priorityQueue.poll();
            if (k == 1) {
                System.out.print(poll);
            } else {
                System.out.print(poll + " ");
            }
        }
    }
}
